package info.cs52.fes.action.dish;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import info.cs52.fes.Application;
import info.cs52.fes.FesAction;
import info.cs52.fes.dao.RecipeDAO;
import info.cs52.fes.data.Recipe;

public class DeleteAction extends FesAction {

	private Recipe dish;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		if (!"confirmed".equals(req.getParameter("confirm"))) {
			dish = RecipeDAO.find(req.getParameter("id"));
		} else {		
			RecipeDAO.delete(req.getParameter("id"));
			resp.sendRedirect(Application.getPath() + "/dish/list");
		}
	}
	
	public Recipe getDish() {
		return dish;
	}
	
}
